package com.chinaisafe.user.dto;

import com.chinaisafe.user.entity.SysTenantApp;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serial;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.io.Serializable;

/**
 * SysTenantAppDTO
 * Description：租户和应用数据传输对象
 *
 * @author tby
 * @date  2024-07-12 10:04:27
 */
@Getter
@Setter
@ToString
@Accessors(chain = true)
@Schema(name = "SysTenantAppDTO", description = "租户和应用数据传输对象")
public class SysTenantAppDTO implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @Schema(description = "主键id")
    private Long id;

    @Schema(description = "租户_id")
    private Long sysTenantId;

    @Schema(description = "应用_id")
    private Long sysAppId;

    @Schema(description = "别名")
    private String alias;

    @Schema(description = "租期")
    private LocalDate tenancyDate;

    @Schema(description = "排序")
    private Integer seq;

    @Schema(description = "0:未集成,1已集成,2,未上架,3已上架")
    private Integer status;


    /**
     * 将实体类转换为数据传输对象
     * @param entity 实体对象
     * @return SysTenantAppDTO 数据传输对象
     * @author tby
     * @date 2024-07-12 10:04:27
     */
    public static SysTenantAppDTO convertFromEntity(SysTenantApp entity) {
        SysTenantAppDTO dto = new SysTenantAppDTO();
        dto.id = entity.getId();
        // 给对应的字段赋值 可根据实际业务删减
        dto.sysAppId = entity.getSysAppId();
        dto.alias = entity.getAlias();
        dto.tenancyDate = entity.getTenancyDate();
        dto.seq = entity.getSeq();
        return dto;
    }
}
